package org.koyi.fragments;

import java.util.List;

import org.koyi.birrapp.DetallesActivity;
import org.koyi.entities.Bares;
import org.koyi.listadapters.DestacadosAdapterListItem;
import org.koyi.singleton.BaresSingleton;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ListView;

public class DestacadosListFragment extends ListFragment {

	private List<Bares> listaBares = null;
	
	@Override
    public void onActivityCreated(Bundle savedInstanceState) 
	{
        super.onActivityCreated(savedInstanceState);
        
        getActivity().setTitle("Locales Destacados");
        
        initializeList();
        
        setListAdapter(new DestacadosAdapterListItem(getActivity(), listaBares));
    }
	
	@Override
	public void onListItemClick(ListView l, View v, int position, long id) 
	{
		super.onListItemClick(l, v, position, id);
		
		Intent intent = new Intent(this.getActivity(), DetallesActivity.class);
		intent.putExtra("selectedBar", (Bares)l.getItemAtPosition(position));
		startActivity(intent);		
	}

	private void initializeList ()
	{
		
		listaBares = BaresSingleton.getListaBares();
	}
}

